﻿<?php
//geändert nochmaldgffgsdfgdfdsfffdgdsfsdfsdf
require_once('konfiguration.html');
$files=array("portuguese_french"=>"Dictionairre De Portugais-Francais.txt",
"french_catalan"=>"Dictionairre Francais-Catalan.txt",
"english_spanish2"=>"Dictionary English Spain.txt",
"german_french"=>"dictionairre allemand francais.txt",
"italian_french"=>"Dictionnaire Italien Francais.txt",
"english_swedish"=>"english -swedish dictionary .txt",
"german_english"=>"German English Dictionary 150000entries.txt",
"italian_english"=>"Italian-English Dictionary.txt",
"spanish_english"=>"Spanish - english dictionary.txt");
foreach ($files as $key=> $value)
{
   $lines=file($value);
   print "$key";
   foreach($lines as $line)
   { 
  
      if (!stristr  ( $line ,  "German-English" ))
      {
      preg_match_all('/^(.*?){(.*?)}[\s]*:[\s]*(.*)/',$line,$matches,PREG_PATTERN_ORDER);
      if (!$matches[3]) 
      { 
         preg_match_all('/^(.*?)[\s]*:[\s]*(.*)/',$line,$matches,PREG_PATTERN_ORDER);
	 print "$key<BR>";
	 if ($matches[2])
	 {
            $word=$matches[1][0];
            $translations=preg_split('/[,;]/',$matches[2][0] );
         }
	 
      }
      else
      {
         $word=$matches[1][0];
	 $gender=$matches[2][0];
	 $translations=preg_split('/[,;]/',$matches[3][0] );
	 $article_translate= array("m"=>"der",
	                           "f"=>"die",
	                           "n"=>"das",
                                   "pl"=>"die");
	 $article= 	$article_translate[$gender];		   
      
      }
      print_r($matches);
      print_r($translations);
      
      
      foreach ($translations as $translation) 
      { 
         if ($translation[-1]=='/') $translation= substr  (  $translation  ,  0  ,-1 );
	 $translation=trim($translation);
        mysql_query("INSERT INTO alltranslations2 (language_combo, word, translation, article,gender) VALUES ('$key','$word',
       '$translation','$article','$gender')");
       
       
      }
       $article="";
       $gender="";      
       $index+=1;
       set_time_limit(10);
      }
      
   }

}
/*$line= "aardvark	oricterope, porco-da-terra[Noun]";
preg_match_all('/^([\w]*)[\s]+([\w-, ]*)\[(.*?)\]/',$line,$matches,PREG_PATTERN_ORDER);
$word=$matches[1];
$translations=explode($matches[2], ',');
$word_class=$matches[3];
print_r ($matches);
*/
//,?(.*?)? \[(.*?)\]+/

?>